Overview

Packages are a way to group Actions, Results, Result Types, Interceptors and Stacks into a logical unit that shares a common configuration. Packages are similiar to objects in that they can be extended and have individual parts overridden by "sub" packages.

Packages

The package element has one required attribute, "name", which acts as the key for later reference to this package. The "extends" attribute is optional and allows one package to inherit the configuration of one or more previous packages including all interceptor, interceptor-stack, and action configurations. Note that the configuration file is processed sequentially down the document, so the package referenced by an "extends" should be defined above the package which extends it. The "abstract" optional attribute allows you to make a package abstract, which will allow you to extend from it without the action configurations defined in the abstract package actually being available at runtime.

Attribute Required Description
name yes key to for other packages to reference
extends no inherits package behavior of the package it extends
namespace no see Namespace Configuration
abstract no declares package to be abstract (no action configurations required in package)

Sample usage of packages in xwork.xml

<xwork>

    <include file="webwork-default.xml" />
    
    <include file="config-browser.xml"/>

	<include file="xwork-messageStore.xml" />

    <include file="xwork-continuations.xml"/>

    <include file="xwork-tags.xml"/>
    
    <include file="xwork-validation.xml" />
    
    <include file="xwork-actionchaining.xml" />

    <include file="xwork-ajax.xml" />

    <include file="xwork-fileupload.xml" />

    <include file="xwork-person.xml" />

    <include file="xwork-wait.xml" />

    <include file="xwork-token.xml" />
    
    <include file="xwork-model-driven.xml" />
    
    <include file="xwork-filedownload.xml" />
    
    <include file="xwork-freemarker.xml" />

	<include file="xwork-wizard.xml" />

    <!-- See Jira http://jira.opensymphony.com/browse/WW-1437 for details -->
    <include file="xwork-sessionInvalidation.xml" />
	
	<include file="xwork-flash.xml" />
	
	<include file="xwork-sitemesh.xml" />

    <include file="xwork-i18n.xml" />

    <package name="default" extends="webwork-default">
        <interceptors>
            <interceptor-stack name="crudStack">
                <interceptor-ref name="params" />
                <interceptor-ref name="defaultStack" />
            </interceptor-stack>
        </interceptors>
		
		<default-action-ref name="showcase"/>
		
        <action name="showcase">
            <result>showcase.jsp</result>
        </action>

        <action name="date" class="com.opensymphony.webwork.showcase.DateAction">
            <result name="success">/date.jsp</result>
        </action>

    </package>

    <package name="skill" extends="default" namespace="/skill">
        <default-interceptor-ref name="crudStack"/>

        <action name="list" class="com.opensymphony.webwork.showcase.action.SkillAction" method="list">
            <result>/empmanager/listSkills.jsp</result>
            <interceptor-ref name="defaultStack"/>
        </action>
        <action name="edit" class="com.opensymphony.webwork.showcase.action.SkillAction">
            <result>/empmanager/editSkill.jsp</result>
            <interceptor-ref name="params" />
            <interceptor-ref name="basicStack"/>
        </action>
        <action name="save" class="com.opensymphony.webwork.showcase.action.SkillAction" method="save">
            <result name="input">/empmanager/editSkill.jsp</result>
            <result type="redirect">edit.action?skillName=${currentSkill.name}</result>
        </action>
        <action name="delete" class="com.opensymphony.webwork.showcase.action.SkillAction" method="delete">
            <result name="error">/empmanager/editSkill.jsp</result>
            <result type="redirect">edit.action?skillName=${currentSkill.name}</result>
        </action>
    </package>

    <package name="employee" extends="default" namespace="/employee">
        <default-interceptor-ref name="crudStack"/>

        <action name="list" class="com.opensymphony.webwork.showcase.action.EmployeeAction" method="list">
            <result>/empmanager/listEmployees.jsp</result>
            <interceptor-ref name="basicStack"/>
        </action>
        <action name="edit" class="com.opensymphony.webwork.showcase.action.EmployeeAction">
            <result>/empmanager/editEmployee.jsp</result>
            <interceptor-ref name="crudStack"><param name="validation.excludeMethods">execute</param></interceptor-ref>
        </action>
        <action name="save" class="com.opensymphony.webwork.showcase.action.EmployeeAction" method="save">
            <result name="input">/empmanager/editEmployee.jsp</result>
            <result type="redirect">edit.action?empId=${currentEmployee.empId}</result>
        </action>
        <action name="delete" class="com.opensymphony.webwork.showcase.action.EmployeeAction" method="delete">
            <result name="error">/empmanager/editEmployee.jsp</result>
            <result type="redirect">edit.action?empId=${currentEmployee.empId}</result>
        </action>
    </package>

</xwork>